<template>
  <div class="imgsInfo-box">
    <h3>{{imgsInfo.title}}</h3>
    <div class="time-click">
      <span>创建时间: {{imgsInfo.add_time | dateFormat}}</span>
      <span>点击次数: {{imgsInfo.click}}</span>
    </div>
    <hr>
    <vue-preview :slides="imgsList" @close="handleClose"></vue-preview>
    <div class="contentt" v-html="imgsInfo.content"></div>

    <comment :id="this.id"></comment>
  </div>
</template>

<script>
import comment from "../common/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      imgsInfo: {},
      imgsList: []
    };
  },
  components: {
    comment
  },
  created() {
    this.getImgInfo();
    this.getImgList();
  },
  methods: {
    handleClose() {},
    getImgInfo() {
      this.$http.get("api/getimageInfo/" + this.id).then(result => {
        this.imgsInfo = result.body.message[0];
        // console.log(this.imgsInfo)
      });
    },
    getImgList() {
      this.$http.get("api/getthumimages/" + this.id).then(result => {
        console.log(result.body.message)
        result.body.message.forEach(element => {
          element.msrc = element.src;
          element.w = 600;
          element.h = 600;
        });
        this.imgsList = result.body.message;
      });
    }
  }
};
</script>

<style lang="scss">
.imgsInfo-box {
  padding: 0 3px;
  .my-gallery {
    display: flex;
    flex-wrap: wrap;
    figure {
      width: 33.333%;
      margin: 0;
      padding: 3px;
      img {
        width: 100%;
      }
    }
  }
  h3 {
    font-size: 14px;
    text-align: center;
  }
  .time-click {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #26a2ff;
  }
  .contentt {
    font-size: 12px;
  }
}
</style>